import { createHashRouter, RouterProvider, Navigate } from "react-router-dom";
import LoginPage from "./page/login";
import App from "./page/app";
import ErrorPage from "./page/error";
import QueryPage from "./page/query";
import Index from "./page/index";
import Fish from "./page/fish";
import Collect from "./page/collect";

const router = createHashRouter([
  {
    element: <Navigate to="/login" replace />,
    index: true,
  },
  {
    // path: "/",
    element: <App />,
    errorElement: <ErrorPage />,
    children: [
      // {
      //   element: <Navigate to="/index" replace />,
      //   index: true,
      // },
      {
        path: "/index",
        element: <Index />,
        // index: true,
      },
      {
        path: "/query",
        element: <QueryPage />,
      },
      {
        path: "/fish",
        element: <Fish />,
      },
      {
        path: "/collect",
        element: <Collect />,
      },
    ],
  },
  {
    path: "/login",
    element: <LoginPage />,
    errorElement: <ErrorPage />,
    index: true,
  },
]);

export const Router = () => <RouterProvider router={router} />;
